package com.rc.saas.mini.service.member;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.mini.mapper.member.MemberAccountRecordMapper;
import com.rc.saas.mini.model.member.MemberAccountRecord;
import com.rc.saas.mini.model.member.MemberAccountRecordExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author wangzhengwei
 * @create 2021/4/26
 */
@Service
public class MemberAccountRecordServiceImpl implements MemberAccountRecordService {
    @Autowired
    private MemberAccountRecordMapper memberAccountRecordMapper;

    @Override
    public MemberAccountRecordMapper getMapper() {
        return memberAccountRecordMapper;
    }

    @Override
    public PageInfo<String> listPageMemberAccountDateRecord(Long memberId, Integer pageSize, Integer pageNo) {
        PageHelper.startPage(pageNo, pageSize);
        List<String> list = memberAccountRecordMapper.listMemberAccountDateRecord(memberId);
        return new PageInfo<>(list);
    }

    @Override
    public List<MemberAccountRecord> listMemberAccountRecord(Long memberId, String yearMonth) {
        List<MemberAccountRecord> accountRecords = memberAccountRecordMapper.listMemberAccountRecord(memberId, yearMonth);
        return accountRecords;
    }

    @Override
    public List<MemberAccountRecord> listByTypeAndMonth(Long memberId, String accountType, String yearMonth,String recordType) {
        return memberAccountRecordMapper.listByTypeAndMonth(memberId, accountType, yearMonth,recordType);
    }

    @Override
    public List<MemberAccountRecord> listMemberAccountRecord(Long memberId) {
        MemberAccountRecordExample example = new MemberAccountRecordExample();
        example.createCriteria().andMemberIdEqualTo(memberId).andRecordTypeEqualTo("0");
        example.setOrderByClause("created_time desc");
        return memberAccountRecordMapper.selectByExample(example);
    }

    @Override
    public List<MemberAccountRecord> listByYesterday(Long memberId) {
        return memberAccountRecordMapper.listByYesterday(memberId);
    }

    @Override
    public List<MemberAccountRecord> listByGetMonth(Long memberId) {
        return memberAccountRecordMapper.listByGetMonth(memberId);
    }

    @Override
    public List<MemberAccountRecord> listPayByTime(Long memberId, Date beginTime, Date endTime) {
        return memberAccountRecordMapper.listPayByTime(memberId, beginTime, endTime);
    }
}
